/**
 * 
 */
package com.broada.apm.service;

import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import com.broada.apm.ajax.Result;
import com.broada.apm.entity.ConfigVariable;
import com.broada.apm.model.Analyzer;
import com.broada.apm.model.Filter;
import com.broada.apm.util.ApiInfo;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;

/**
 * 协议分析器管理
 * @author admin
 *
 */
@Path("apm/analyzers")
@Api(value="apm/analyzers" , description = "协议分析器管理")
@Produces(MediaType.APPLICATION_JSON)
public interface AnalyzerService {
	
	/**
	 * 查询所有协议分析器
	 * @return
	 */
	@GET
	@ApiOperation(value = "查询所有协议分析器信息")
	@Produces(MediaType.APPLICATION_JSON)
	public Result getAllAnalyzer(
			@ApiParam(value = "页码", required = true) @QueryParam("pageIndex") int pageIndex,
			@ApiParam(value = "每页显示的查询记录数", required = true) @QueryParam("pageSize") int pageSize);
	
	@GET
	@Path("/{analyzerId}/info")
	@ApiOperation(value = "查询所有协议分析器信息")
	@Produces(MediaType.APPLICATION_JSON)
	public Result getAnalyzerById(@ApiParam(value = "协议分析器id", required = true) @PathParam("analyzerId") String analyzerId);
	
	@GET
	@Path("/{analyzerId}")
	@ApiOperation(value = "查询协议分析器日志信息")
	@Produces(MediaType.APPLICATION_JSON)
	public Result getAnalyzerLog(@ApiParam(value = "协议分析器id", required = true) @PathParam("analyzerId") String analyzerId);
	
	/**
	 * 增加协议分析器信息 
	 * @param name
	 * @param ip
	 * @param port
	 * @return
	 */
	@POST
	@ApiOperation(value = "增加协议分析器信息")
	@Produces(MediaType.APPLICATION_JSON)
	public Result addAnalyzer(@ApiParam(value = "所要提交的协议分析器信息", required = true) Analyzer analyzer);
	
	@GET
	@Path("reload/{analyzerId}")
	@ApiOperation(value = "协议分析器尝试启用/禁用")
	@Produces(MediaType.APPLICATION_JSON)
	public Result reloadProtocol(@ApiParam(value = "协议分析器id", required = true) @PathParam("analyzerId") String analyzerId);
	
	/**
	 * 删除协议分析器信息
	 * @param id
	 * @return
	 */
	@DELETE
	@Path("/{id}")
	@ApiOperation(value = "删除协议分析器信息")
	@Produces(MediaType.APPLICATION_JSON)
	public Result deleteAnalyzer(@ApiParam(value = "协议分析器id", required = true) @PathParam("id") String id);
	
	/**
	 * 根据analyzerId，显示数据包过滤列表信息
	 * @param tab
	 * @param 
	 * @return
	 */
	@GET
	@Path("/{analyzerId}/filters")
	@ApiOperation(value = "根据analyzerId，显示数据包过滤列表信息")
	@Produces(MediaType.APPLICATION_JSON)
	public Result getFilters(@ApiParam(value = "协议分析器id", required = true) @PathParam("analyzerId") String analyzerId);
	
	/**
	 * 配置数据包过滤规则信息 
	 * @param variable
	 * @param analyzerId
	 * @return
	 */
	@POST
	@Path("/filters/{analyzerId}")
	@ApiOperation(value = "配置数据包过滤规则信息，修改顺序 ")
	@Produces(MediaType.APPLICATION_JSON)
	public Result addDataFilter(
			@ApiParam(value = "提交的数据包过滤规则信息", required = true) ConfigVariable variable, 
			@ApiParam(value = "协议分析器id", required = true) @PathParam("analyzerId") String analyzerId);

	/**
	 * 配置数据包过滤规则信息 
	 * @param variable
	 * @param analyzerId
	 * @return
	 */
	@POST
	@Path("/filter")
	@ApiOperation(value = "配置数据包过滤规则信息")
	@Produces(MediaType.APPLICATION_JSON)
	public Result addFilter(@ApiParam(value = "提交的数据包过滤规则信息", required = true) Filter filter);
	
	/**
	 * 删除数据包过滤规则信息 
	 * @param variable
	 * @param analyzerId
	 * @return
	 */
	@DELETE
	@Path("/filters/{analyzerId}")
	@Produces(MediaType.APPLICATION_JSON)
	public Result deleteDataFilter(
			@ApiParam(value = "协议分析器id", required = true) @PathParam("analyzerId") String analyzerId, 
			@ApiParam(value = "数据包过滤规则id", required = true) @QueryParam("id") String id);
}
